package com.ch.home.testService;

import com.ch.home.bean.UserComment;
//import com.ch.home.service.UserCommentServiceImpl;
import com.ch.home.service.serviceImpl.userServiceImpl.UserCommentServiceImpl;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Date;
import java.util.HashMap;
import java.util.Random;

/**
 * Created by CHEN on 2019/8/19.
 */
@RunWith(SpringRunner.class)
@SpringBootTest
public class testUserCommentServiceImpl {
    @Autowired
    UserCommentServiceImpl userCommentServiceImpl;

    @Test
    public void testInsertUserComment(){

        Date date =new Date();
        UserComment userComment = new UserComment(null, 8, 1, 2, date, "测试评论", 0, 0,0);

        HashMap map = userCommentServiceImpl.insertUserComment(userComment);

        System.out.println(map );

    }


    @Test
    public void testSelectByUserId() {
        UserComment userComment = new UserComment( );
        userComment.setParentCommentId(1);
//        userComment.setUserId(1);
        HashMap hashMap = userCommentServiceImpl.selectByUserId(userComment);
        System.out.println(hashMap);
    }


    @Test
    public void testUpdateUser() {

        UserComment userComment = new UserComment( );
        userComment.setCommentId(1);
//        userComment.setStatus(1);

//        userComment.setLikeNum(1);
        userComment.setLikeNum(-1);

        HashMap map = userCommentServiceImpl.updateUser(userComment);

        System.out.println(map);
    }


//    //ok
//    @Test
//    public void testGetUserCommentFromMap() {
//        HashMap<Object, Object> map = new HashMap<>( );
//        map.put("commentId", 1);
//        map.put("userId", 1);
//        map.put("shareContentId", 1);
//        map.put("parentCommentId", 1);
//        map.put("time", new Date( ));
//        map.put("content", "aweqweqwasd");
//        map.put("likeNum", 123);
//        map.put("status", 1);
//
//        UserComment userComment = userCommentServiceImpl.getUserCommentFromMap(map);
//        System.out.println("------------------------------------------------------------");
//        System.out.println(userComment);
//        System.out.println("------------------------------------------------------------");
//    }

    @Test
    public void test() {
        Random random = new Random( );
        random.nextInt(5);
        for (int i =0;i<20;i++)
        System.out.println(random.nextInt(5));
    }

}
